<template>
  <el-dialog title="选择素材" :visible.sync="dataVisible" :modal="true" append-to-body @close="onClose">
    <material-news v-if="selectType=='news'" select-mode @selected="onSelect" />
    <material-file v-else :file-type="selectType" select-mode @selected="onSelect" />
  </el-dialog>
</template>
<script>
export default {
  name: 'AssetsSelector',
  components: {
    MaterialFile: () => import('./material-file'),
    MaterialNews: () => import('./material-news')
  },
  props: {
    selectType: { // image、voice、video、news
      type: String,
      default: 'image'
    },
    visible: {
      type: Boolean,
      default: false
    }
  },
  data: function() {
    return {
      dataVisible: this.visible
    }
  },
  methods: {
    onSelect(itemInfo) {
      this.$emit('selected', itemInfo)
    },
    onClose() {
      this.$emit('onClose')
    }
  }
}
</script>
